﻿

using IotContract.Configs;
using IotContract.Dtos.Clients;
using IotContract.Dtos.Servers;
using IotContract.Dtos.Servers.Pushs;
using IotContract.Models;
using IotContract.Models.Clients;
using IotContract.Models.Clients.Hks;
using IotContract.Models.Process;
using IotContract.Models.Webs;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace IotContract.Interfaces;
/// <summary>
/// 连接、配置等数据
/// 服务端实现
/// 客户端实现需要grpc调用
/// </summary>
public interface IConnectDataService
{
    /// <summary>
    /// 地址配置
    /// </summary>
    public AddressConfig AddressConfig { get; set; }
    /// <summary>
    /// 提交状态,返回是否启用
    /// </summary>
    /// <returns>是否启用</returns>
    Task<int> CommitStatus(ClientStatusCommand clientStatus);

    /// <summary>
    /// 添加程序
    /// </summary>
    /// <param name="clientConnect"></param>
    /// <returns></returns>
    Task<(IotProgramDto, string)> AddProgram(ClientConnectCommand clientConnect);





    /// <summary>
    /// 读取所有程序控制指令
    /// </summary>
    /// <param name="programId"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    IAsyncEnumerable<ClientControlCommand> ReadControl(long programId, CancellationToken token);
    /// <summary>
    /// 推送设备数据
    /// </summary>
    /// <param name="equips"></param>
    /// <returns></returns>
    Task<List<OperationWriteCommand>> PushEquips< T>(List<T> equips) where T : IPushEquip;
 

    /// <summary>
    /// 获取设备数据
    /// </summary>
    /// <param name="command"></param>
    /// <returns></returns>
     Task<(List<IotEquipDto>, string)> GetEquips(ClientRequestCommand command);
    /// <summary>
    /// 获取设备点位数据
    /// </summary>
    /// <param name="command"></param>
    /// <returns></returns>
    Task<(List<EquipTagDto>,string)> GetEquipTags(ClientRequestCommand command);




    /// <summary>
    /// 获取调度数据
    /// </summary>
    /// <param name="command"></param>
    /// <returns></returns>
    Task<List<ProcessBaseData>> GetProcessDatas(ProcessProviderCommand command);

    /// <summary>
    /// 添加调度任务
    /// </summary>
    /// <param name="command"></param>
    /// <returns></returns>
    Task<string> AddProcessJob(ProcessJobCommand command);


    /// <summary>
    /// 添加Web控制
    /// </summary>
    /// <param name="control"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    Task<string> AddWebControl(WebControlModel control);




    #region 弃用
    /// <summary>
    /// 提交设备报警
    /// </summary>
    /// <param name="iotEquipWarnDto"></param>
    /// <returns></returns>
    Task<GrpcReturn<string>> CommitFireWarn(IotEquipWarnDto iotEquipWarnDto);
    /// <summary>
    /// 提交充放电结果
    /// </summary>
    /// <param name="result"></param>
    /// <returns>构造好的报文</returns>
    Task<GrpcReturn<string>> CommitChargeFMTResult(ChargeTrayResult result);
    /// <summary>
    /// 提交库位移动指令
    /// </summary>
    /// <param name="moveInstruct"></param>
    /// <returns></returns>
    Task<GrpcReturn<string>> CommitFmtMove(StageMoveInstruct moveInstruct);
    /// <summary>
    /// 获取组盘信息
    /// </summary>
    /// <param name="trayDefineInstruct"></param>
    /// <returns>状态，code,msg</returns>
    Task<GrpcReturn<TrayCellStatus>> GetTrayCellStatus(TrayDefineInstruct trayDefineInstruct);


    /// <summary>
    /// 提交OCV结果
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>

    Task<GrpcReturn<OCVCellMain>> CommitOcvResult(OCVTrayResult data);
    /// <summary>
    /// 获取复测配方
    /// </summary>
    /// <param name="hkWrite"></param>
    /// <returns></returns>
    Task<GrpcReturn<string>> GetReTestChargeFMT(HkWriteInstruct hkWrite);
    /// <summary>
    /// 获取充放电配方
    /// </summary>
    /// <param name="hkWrite"></param>
    /// <returns></returns>
    Task<GrpcReturn<string>> GetChargeFMTData(HkWriteInstruct hkWrite);
    /// <summary>
    /// 校验NG托盘
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    Task<GrpcReturn<string>> CheckNGResult(HkWriteInstruct data);
    /// <summary>
    /// 获取筛选机的电芯数据
    /// </summary>
    /// <param name="trayCode"></param>
    /// <returns></returns>
    Task<GrpcReturn<SelCellResult>> GetSelCellData(HkWriteInstruct data);
    /// <summary>
    /// 提交筛选结果
    /// </summary>
    /// <param name="trayCode"></param>
    /// <returns></returns>
    Task<GrpcReturn<string>> CommitSelResult(HkWriteInstruct data); 
    #endregion

}
